import java.util.Scanner;

public class test2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int[] a=new int[100];
        int b=input.nextInt();
        for(int i=0;i<b;i++)
            a[i]= input.nextInt();
        System.out.println(sumParams(a));
    }
        public static int sumParams(int[] nums) {
            int maxSum = 0;
            for (int i = 0; i < nums.length; i++) {
                int sum = 0;
                for (int j = i; j < nums.length; j++) {
                    sum = sum + nums[j];
                    if (sum > maxSum) {
                        maxSum = sum;
                    }
                }
            }
            return maxSum;
        }
}
